package com.junchenrobot.mes.service.impl;

import com.junchenrobot.mes.dao.WinderDao;
import com.junchenrobot.mes.domain.Winder;
import com.junchenrobot.mes.service.WinderService;
import com.junchenrobot.mes.vo.WinderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class WinderServiceImpl implements WinderService {
    
    private final WinderDao winderDao;
    
    @Autowired
    public WinderServiceImpl(WinderDao winderDao) {
        this.winderDao = winderDao;
    }
    
    
    @Override
    public List<WinderVo> listWinder() {
        List<Winder> winders = winderDao.listWinder();
        return winders.stream()
                      .map(v -> {
                          WinderVo winderVo = new WinderVo();
                          winderVo.setWinderId(v.getId());
                          winderVo.setWinderName(v.getWinderName());
                          return winderVo;
                      }).collect(Collectors.toList());
    }
}
